//
//  TTHelpViewItem.m
//  ineedish
//
//  Created by Felipe Navarro V. on 31-10-09.
//  Copyright 2009 deis. All rights reserved.
//
#import <QuartzCore/QuartzCore.h>
#import "TTHelpView.h"
#import "INDefaultStylesheet.h"


static CGFloat kImageWidth = 55;
//static CGFloat kImageHeight = 55;
static const CGFloat kSmallMargin = 6;



@implementation TTHelpView

- (void)layoutSubviews {
	[super layoutSubviews];	
	self.backgroundColor = [UIColor whiteColor];
//	TTView* view = [[[TTView alloc] initWithFrame:frame] autorelease];
//	self.view

	//Style Right
//	TTStyle* styleR = [TTShapeStyle styleWithShape:[TTSpeechBubbleShape shapeWithRadius:5 pointLocation:20
//														   pointAngle:320
//															pointSize:CGSizeMake(10,10)] next:
//	 [TTSolidFillStyle styleWithColor:[UIColor whiteColor] next:
//	 [TTSolidBorderStyle styleWithColor:[UIColor blackColor] width:1 next:nil]]];
	//Style Left
	TTStyle* style = [TTShapeStyle styleWithShape:[TTSpeechBubbleShape shapeWithRadius:5 pointLocation:200
														   pointAngle:160
															pointSize:CGSizeMake(20,10)] next:
	 [TTSolidFillStyle styleWithColor:[UIColor whiteColor] next:
	  [TTSolidBorderStyle styleWithColor:[UIColor grayColor] width:1 next:nil]]];					   
	
	
	NSString* remoteImage = @"http://profile.ak.fbcdn.net/v223/35/117/q223792_6978.jpg";		
	TTImageView* _imageView = [[TTImageView alloc] initWithFrame:CGRectZero];
	
	TTStyledTextLabel* label1 = [[[TTStyledTextLabel alloc] initWithFrame:CGRectZero] autorelease];
	
	//	TTNeedTableViewController *Helps = [[TTNeedTableViewController alloc] autorelease];
	
	_imageView.URL = remoteImage;
	
	
	CALayer * imglayer = [_imageView layer];
	[imglayer setMasksToBounds:YES];
	[imglayer setCornerRadius:10.0];
	[imglayer setBorderWidth:0.5];
	[imglayer setBorderColor:[TTSTYLEVAR(needPictureUrlBorderColor) CGColor]];
	
	
	//Label DisplayName
	label1.font = TTSTYLEVAR(needSubjectFont);
	
	label1.text = [TTStyledText textFromXHTML:@"Dude" lineBreaks:YES URLs:YES];
	//	label1.contentInset = UIEdgeInsetsMake(10, 10, 10, 10);
	label1.textColor = TTSTYLEVAR(needSubjectColor);
	label1.backgroundColor = [UIColor clearColor];
	//	label1.fon
	[label1 sizeToFit];

	self.top = 4;
	self.height		= self.height +84;
//	CGFloat x = 0;
	CGFloat y = 4;
	CGFloat viewWidth = self.width +2;
	CGFloat viewHeight = self.height-4;


	
	CGRect frame = CGRectMake(kImageWidth - kSmallMargin*2, y, viewWidth - kImageWidth - kSmallMargin*2, viewHeight - kSmallMargin);
//	TTView* aview = [[[TTView alloc] initWithFrame:frame] autorelease];
	TTView* aview = [[[TTView alloc] initWithFrame:frame] autorelease];
//	self.aview.frame = frame;
	aview.backgroundColor = self.backgroundColor;
	aview.style = style;

//	self.height=aview.height;
	
	[self addSubview:aview];	

	_imageView.top = y;
	[self addSubview:_imageView];	
	self.backgroundColor = [UIColor cyanColor];
}

- (void)dealloc {
	[super dealloc];
}


@end
